package com.dfrz.stockMarket.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dfrz.stockMarket.bean.MessageBean;
import com.dfrz.stockMarket.bean.UserBean;
import com.dfrz.stockMarket.model.UserOrderModel;
import com.dfrz.stockMarket.model.UserStocksModel;
import com.dfrz.stockMarket.service.UserService;

public class InfoPageCtrl  extends BaseController{
	@Override 
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8"); 
		resp.setCharacterEncoding("utf-8");
		String path = req.getContextPath();
		UserBean userBean = getSessionUserBean(req);
		UserService server =new UserService();
		String name=userBean.getUserInfoModel().getUserName();
		UserBean ub=new UserBean();
		try {
			MessageBean massa=	server.getUserBeanByName(name);
			ub=(UserBean) massa.getMsg();
			System.out.println("ub---"+ub);
			List<UserOrderModel> userordermodel = ub.getUserOrderModels();
			
			System.out.println("InfoPageCtrl-userordermodel"+userordermodel);
			setSession(req, "list", userordermodel);
			req.setAttribute("uname", name);
			req.setAttribute("path", path);
			req.getRequestDispatcher("/WEB-INF/page/Info.jsp").forward(req, resp);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		

	}

}
